<?php
defined('SEJUJOPEFDNGJSL') or exit('Access denied');

if($_POST['act']=='add'){
    $rates1 = $_POST['rates1']?$_POST['rates1']:0;
    $rates2 = $_POST['rates2']?$_POST['rates2']:0;
    $rates3 = $_POST['rates3']?$_POST['rates3']:0;
    $rates4 = $_POST['rates4']?$_POST['rates4']:0;
    $rates5 = $_POST['rates5']?$_POST['rates5']:0;

    $teams1 = $_POST['teams1']?$_POST['teams1']:0;
    $teams2 = $_POST['teams2']?$_POST['teams2']:0;
    $teams3 = $_POST['teams3']?$_POST['teams3']:0;
    $teams4 = $_POST['teams4']?$_POST['teams4']:0;
    $teams5 = $_POST['teams5']?$_POST['teams5']:0;
    $day[] = $_POST['day1'];
    $day[] = $_POST['day2'];
    $day[] = $_POST['day3'];
    $day[] = $_POST['day4'];
    $day[] = $_POST['day5'];
    $day[] = $_POST['day6'];
    $msg = '';
    foreach($day as $k => $v){
    	$sql_meal = "update ld_set_meal set min = ".$v['min'].",max = ".$v['max'].",days=".$v['days'].",meal=".$v['meal']." where id = ".$v['id'];
    	$db->sitedbexec($sql_meal);
    }

	$sql = 'update ld_settings set setting_value = CASE setting_enname
	WHEN \'rates1\' THEN \''.$rates1.'\'
	WHEN \'rates2\' THEN \''.$rates2.'\'
	WHEN \'rates3\' THEN \''.$rates3.'\'
	WHEN \'rates4\' THEN \''.$rates4.'\'
	WHEN \'rates5\' THEN \''.$rates5.'\'
	WHEN \'teams1\' THEN \''.$teams1.'\'
	WHEN \'teams2\' THEN \''.$teams2.'\'
	WHEN \'teams3\' THEN \''.$teams3.'\'
	WHEN \'teams4\' THEN \''.$teams4.'\'
	WHEN \'teams5\' THEN \''.$teams5.'\'
	END
	where setting_enname in (\'teams1\',\'teams2\',\'teams3\',\'teams4\',\'teams5\'
	,\'rates5\',\'rates4\',\'rates3\',\'rates2\',\'rates1\')';
	$db->sitedbexec($sql);
	record_log('修改团队参数'.$uname);
	show_automsg('修改团队参数成功！',YMCURL.'teamset');
}
$param = [];
foreach($GLOBALARR as $k => $v){
	if(preg_match('/^day\d+$/',$k)){
		$db->query("select * from ld_set_meal where id = ".$v,2);
		$param[$k] = $db -> rs;
	}
}
echo '<h3>参数设置</h3>';
echo '<script language="javascript" type="text/javascript" src="../my97datepicker/WdatePicker.js"></script>';
echo '<div class="main-r-body"><form method="post" action="'.geturl().'">
		<div class="main-r-item">
		<input type="submit" class="thabtn" value="保存"></div>
		<input type="hidden" name="act" value="add">';
echo '<table class="tregtab ttab">';
echo '<tr>
		<td colspan="6" >会员锁仓收益设置</td>
		
	  </tr>';
for($i =0 ; $i < count($param);$i++){
	if($i%2 == 0){
		print('<tr>');
		print('<td class="wdb20 alignr paddingr" style="width:10%">'.$param['day'.($i+1)]['title'].'</td>
		<td class="alignl paddingl">
			数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量： <input type="text" name="day'.($i+1).'[min]" value="'.$param['day'.($i+1)]['min'].'" class="thconfig wd200"> 
				--
			<input type="text" name="day'.($i+1).'[max]" value="'.$param['day'.($i+1)]['max'].'" class="thconfig wd200">个<br />
			锁仓时间：<input type="text" name="day'.($i+1).'[days]" value="'.$param['day'.($i+1)]['days'].'" class="thconfig wd200">天<br />
			日&nbsp;&nbsp;&nbsp;收益：<input type="text" name="day'.($i+1).'[meal]" value="'.$param['day'.($i+1)]['meal'].'" class="thconfig wd200"><input type="hidden" name="day'.($i+1).'[id]" value="'.$param['day'.($i+1)]['id'].'" class="thconfig wd200">
		</td>');
	}else{
		print('<td class="wdb20 alignr paddingr" style="width:10%">'.$param['day'.($i+1)]['title'].'</td>
		<td class="alignl paddingl">
			数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量： <input type="text" name="day'.($i+1).'[min]" value="'.$param['day'.($i+1)]['min'].'" class="thconfig wd200"> 
				--
			<input type="text" name="day'.($i+1).'[max]" value="'.$param['day'.($i+1)]['max'].'" class="thconfig wd200">个<br />
			锁仓时间：<input type="text" name="day'.($i+1).'[days]" value="'.$param['day'.($i+1)]['days'].'" class="thconfig wd200">天<br />
			日&nbsp;&nbsp;&nbsp;收益：<input type="text" name="day'.($i+1).'[meal]" value="'.$param['day'.($i+1)]['meal'].'" class="thconfig wd200"><input type="hidden" name="day'.($i+1).'[id]" value="'.$param['day'.($i+1)]['id'].'" class="thconfig wd200">
		</td>');
		print('</tr>');
	}
}

echo '<table class="tregtab ttab">';
echo '<tr>
		<td colspan="4">购买额度达到,推荐人受益</td>
		
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">1-999枚，推荐日收益</td>
		<td class="alignl paddingl"><input type="text" name="rates1" value="'.$GLOBALARR['rates1'].'" class="thconfig wd200">%</td>
		<td class="wdb20 alignr paddingr">1000-2999枚，推荐日收益</td>
		<td class="alignl paddingl"><input type="text" name="rates2" value="'.$GLOBALARR['rates2'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">3000-4999枚，推荐日收益</td>
		<td class="alignl paddingl"><input type="text" name="rates3" value="'.$GLOBALARR['rates3'].'" class="thconfig wd200">%</td>
		<td class="wdb20 alignr paddingr">5000-9999枚，推荐日收益</td>
		<td class="alignl paddingl"><input type="text" name="rates4" value="'.$GLOBALARR['rates4'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">10000枚以上，推荐日收益</td>
		<td class="alignl paddingl"><input type="text" name="rates5" value="'.$GLOBALARR['rates5'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '</table>';


echo '<table class="tregtab ttab">';
echo '<tr>
		<td colspan="2">推荐人团队日收益</td>
		
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">推荐2人以上，推荐人每日收益团队总量的</td>
		<td class="alignl paddingl"><input type="text" name="teams1" value="'.$GLOBALARR['teams1'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">推荐4人以上，推荐人每日收益团队总量的</td>
		<td class="alignl paddingl"><input type="text" name="teams2" value="'.$GLOBALARR['teams2'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">推荐6人以上，推荐人每日收益团队总量的</td>
		<td class="alignl paddingl"><input type="text" name="teams3" value="'.$GLOBALARR['teams3'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">推荐8人以上，推荐人每日收益团队总量的</td>
		<td class="alignl paddingl"><input type="text" name="teams4" value="'.$GLOBALARR['teams4'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '<tr>
		<td class="wdb20 alignr paddingr">推荐10人以上，推荐人每日收益团队总量的</td>
		<td class="alignl paddingl"><input type="text" name="teams5" value="'.$GLOBALARR['teams5'].'" class="thconfig wd200">%</td>
	  </tr>';
echo '</table>';

echo '</form></div>';
